package com.lvyq.myplayer.model.collect

import androidx.lifecycle.ViewModel
import com.lvyq.myplayer.dao.PlayCollectDao
import kotlinx.coroutines.flow.Flow
/**
 * 文件描述：PlayHistoryViewModel
 * 作者：lvyq
 * 创建时间：2025-06-16
 * 修改时间：2025-06-16
 */
class PlayCollectViewModel(private val playCollectDao: PlayCollectDao) : ViewModel() {

     fun getAllPlayCollectListFlow(type: Int):Flow<List<PlayCollectEntity> >{
       return playCollectDao.getAllPlayCollectListFlow(type)
    }

     suspend fun insertPlayCollect(data: PlayCollectEntity) {
         playCollectDao.insertPlayCollect(data)
     }

    suspend fun deletePlayCollect(data: PlayCollectEntity) {
        playCollectDao.deletePlayCollect(data)
    }
    suspend fun deleteByIds(ids: List<Int>) {
        playCollectDao.deleteByIds(ids)
    }

    suspend fun updatePlayCollect(data: PlayCollectEntity){
        playCollectDao.updatePlayCollect(data)
    }

    suspend fun getPlayCollectByBusinessKeyAndType(businessKey:Int,type:Int):PlayCollectEntity?{
       return playCollectDao.getPlayCollectByBusinessKeyAndType(businessKey,type)
    }
     fun count(type: Int):Flow<Long>{
       return playCollectDao.count(type)
    }
    fun count():Flow<Long>{
        return playCollectDao.count()
    }
    suspend fun deleteByBusinessKey(businessKey: Int,type:Int){
        playCollectDao.deleteByBusinessKey(businessKey,type)
    }

}
